/**
 * 
 */
package info.niwota.start.app;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.CheckedTextView;
import android.widget.RelativeLayout;

/**
 * @author qiangli
 * 
 */
public class CheckedRelativeLayout extends RelativeLayout implements Checkable {
	private CheckedTextView text1;

	/**
	 * @param context
	 */
	public CheckedRelativeLayout(Context context) {
		super(context);
	}

	/**
	 * @param context
	 * @param attrs
	 */
	public CheckedRelativeLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	/**
	 * @param context
	 * @param attrs
	 * @param defStyle
	 */
	public CheckedRelativeLayout(Context context, AttributeSet attrs,
			int defStyle) {
		super(context, attrs, defStyle);
	}

	private CheckedTextView findCheckedTextView() {
		if (text1 == null) {
			text1 = (CheckedTextView) findViewById(android.R.id.text1);
		}
		return text1;
	}

	public boolean isChecked() {
		CheckedTextView ctv = findCheckedTextView();
		return ctv.isChecked();
	}

	public void setChecked(boolean checked) {
		CheckedTextView ctv = findCheckedTextView();
		ctv.setChecked(checked);
	}

	public void toggle() {
		CheckedTextView ctv = findCheckedTextView();
		ctv.toggle();
	}

}
